package io.renren.modules.secretary.controller;

import io.renren.common.utils.R;
import io.renren.modules.common.entity.CensusEntity;
import io.renren.modules.secretary.service.SecretaryCensusService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.sql.Date;
import java.util.List;


/**
 * @author guijing
 * @email sunlightcs@gmail.com
 * @date 2022-03-28 20:16:37
 */
@RestController
@RequestMapping("secretary/census")
@Transactional
public class SecretaryCensusController {

    @Autowired
    SecretaryCensusService secretaryCensusService;

    /**
     * 书记获取打卡情况
     */
    @RequestMapping("/sector/{date}")
    public R sector(@PathVariable("date") Date date) {

        CensusEntity censusEntity = secretaryCensusService.sectorList(date);

        return R.ok().put("census", censusEntity);
    }

    /**
     * 书记获取班级打卡情况
     */
    @RequestMapping("/rectangle/{date}")
    public R rectangle(@PathVariable("date") Date date) {

        List<CensusEntity> censusEntities = secretaryCensusService.rectangleList(date);

        return R.ok().put("census", censusEntities);
    }


}
